﻿package mortal.game.view.mainUI.petAvatar
{
    import Message.Game.*;
    import Message.Public.*;
    import mortal.game.events.*;
    import mortal.game.model.vo.pet.*;
    import mortal.game.scene3D.player.info.*;
    import mortal.game.utils.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class PetAvatarController extends Controller
    {
        protected var _petAvatar:PetAvatarView;
        protected var _pet:SPet;

        public function PetAvatarController()
        {
            return;
        }// end function

        override protected function initView() : IView
        {
            if (!this._petAvatar)
            {
                this._petAvatar = new PetAvatarView();
            }
            return this._petAvatar;
        }// end function

        override protected function initServer() : void
        {
            return;
        }// end function

        private function refreshDrugNum(param1:Object) : void
        {
            if (!view.isHide)
            {
                this._petAvatar.refreshDrugNum();
            }
            return;
        }// end function

        private function updateCd(param1:Object = null) : void
        {
            if (!view.isHide)
            {
                this._petAvatar.updateCd();
            }
            return;
        }// end function

        protected function onPetInfoUpdate(param1:Object = null) : void
        {
            var _loc_2:Boolean = false;
            var _loc_4:SPet = null;
            return;
            if (cache.pet.pets.length > 0)
            {
                if (view && _loc_2 == false)
                {
                    if (view.isHide)
                    {
                        view.show();
                    }
                    (view as PetAvatarView).updatePet(PetUtil.avatarPet);
                    (view as PetAvatarView).specialUpdate();
                    (view as PetAvatarView).updateEntityInfo(null);
                }
            }
            else if (isViewShow)
            {
                view.hide();
            }
            return;
        }// end function

        protected function onFightPetUpdate(param1:SPet) : void
        {
            var _loc_2:EntityInfo = null;
            if (param1)
            {
                (view as PetAvatarView).updatePet(param1);
                this._pet = param1;
                if (!isViewShow)
                {
                    view.show();
                }
                _loc_2 = cache.entity.getEntityInfoById(param1.publicPet.entityId);
                if (_loc_2)
                {
                    (view as PetAvatarView).updateEntityInfo(_loc_2);
                }
            }
            return;
        }// end function

        protected function onUpdatePet(param1:SPet) : void
        {
            if (param1.publicPet.state == EPetState._EPetStateActive)
            {
                this.onFightPetUpdate(param1);
            }
            else if (this._pet && param1.publicPet.uid == this._pet.publicPet.uid)
            {
                (view as PetAvatarView).updatePet(param1);
            }
            return;
        }// end function

        protected function onPetAddOrRemove(param1:SPetUpdate) : void
        {
            if (param1.updateType == EUpdateType._EUpdateTypeDel)
            {
                if (this._pet && this._pet.publicPet.uid == param1.uid)
                {
                    this.onPetInfoUpdate();
                }
            }
            return;
        }// end function

        protected function onPetDead(param1:SPet) : void
        {
            if (param1.publicPet.uid != cache.pet.fightPetUid)
            {
                return;
            }
            (view as PetAvatarView).onPetDead();
            return;
        }// end function

        protected function onAddSelfPet(event:DataEvent) : void
        {
            if (!isViewShow)
            {
                view.show();
            }
            var _loc_2:* = event.data as EntityInfo;
            (view as PetAvatarView).updateEntityInfo(_loc_2);
            return;
        }// end function

        protected function onChangePetMode(event:DataEvent) : void
        {
            var _loc_2:* = event.data as PetChangeModeVO;
            return;
        }// end function

        private function onAvatarAdjust(event:DataEvent) : void
        {
            PetAvatarView(view).isInPetBreakCopy(event.data);
            return;
        }// end function

        private function setSliderValue(param1:Object = null) : void
        {
            (view as PetAvatarView).setSliderValue();
            return;
        }// end function

    }
}
